#include "EWAUITrackHeader.hpp"

#include "EWAPrjTrackUI.hpp"

namespace Eyer
{
    EWAUITrackHeader::EWAUITrackHeader(EyerSmartPtr<EWAUITimelineContext> _timelineCtx, EWAUILayoutParams width, EWAUILayoutParams height)
        : EWAUIWidget(width, height)
        , timelineCtx(_timelineCtx)
    {
        SetWidgetName("EWAUITrackHeader");
        timelineCtx->RegisterListener(this);
    }

    EWAUITrackHeader::~EWAUITrackHeader()
    {
        timelineCtx->UnregisterListener(this);
    }

    int EWAUITrackHeader::SetTrackHeaderWidth(int trackHeaderWidth)
    {
        EWAPrjTrackType trackType = EWAPrjTrackType::VIDEO;
        for(int i = 0; i < timelineCtx->timeline.GetTrackCount(trackType); i++) {
            const EyerSmartPtr<EWAPrjTrackUI> & track = timelineCtx->timeline.GetTrack(i, trackType);

            EyerSmartPtr<EWAUITrackHeaderItem> item = track->item;
            EyerSmartPtr<EWAUIWidgetVerticalSegBar> segBar = track->segBar;

            item->SetMinWidth(trackHeaderWidth);
            segBar->SetMinWidth(trackHeaderWidth);
        }

        return 0;
    }

    int EWAUITrackHeader::OnDraw()
    {
        return 0;
    }

    bool EWAUITrackHeader::OnMousePressEvent     (const Vec2I & pos)
    {
        return true;
    }

    bool EWAUITrackHeader::OnMouseReleaseEvent   (const Vec2I & pos)
    {
        return true;
    }

    bool EWAUITrackHeader::OnMouseMoveEvent      (const Vec2I & pos)
    {
        return true;
    }

    int EWAUITrackHeader::OnTrackUpdate(EWAPrjTimeline * timeline)
    {
        return 0;
    }
}